﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.Flexibles.CApCableRotatingAttachmentControl
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Threading;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using Tecnomatix.Engineering.Ui.WPF;


namespace DnProcessSimulateCommands.Flexibles;

public class CApCableRotatingAttachmentControl : 
  UserControl,
  ICUiFLEXAttachmentEditControl,
  IComponentConnector
{
  internal Border RotatingAttachmentBorder;
  internal Canvas CanvasRotatingAttachment;
  internal Path BackgroundLayerRotating;
  internal Canvas EndFrameAxesRotating;
  internal Canvas EndFramePointerRotating;
  internal TextBlock EndFrameLabelRotating;
  internal Canvas StartFrameAxesRotating;
  internal Canvas StartFramePointerRotating;
  internal TextBlock StartFrameLabelRotating;
  internal Canvas AttachmentFramePointerRotating;
  internal TextBlock AttachmentFrameLabelRotating;
  internal Canvas AttachmentFrameAxesRotating;
  internal Path AttachmentXAxisLineRotating;
  internal Path AttachmentXAxisArrowRotating;
  internal Path AttachmentYAxisLineRotating;
  internal Path AttachmentYAxisArrowRotating;
  internal Path AttachmentAnyAxisLineRotating;
  internal Path AttachmentAnyAxisArrowRotating;
  internal Path CableSimulatedSection1Rotating;
  internal Path CableSimulatedSection2Rotating;
  internal Grid RotationArrowRotating;
  internal Path RotationArrowLeftLineRotating;
  internal Path RotationArrowLeftCapRotating;
  internal Path RotationArrowRightLineRotating;
  internal Path RotationArrowRightCapRotating;
  internal Path DistanceFromStartFocusRotating;
  internal Path DistanceFromStartPathRotating;
  internal Canvas DistanceFromStartPointerRotating;
  internal TextBlock DistanceFromStartLabelRotating;
  internal Rectangle AttachmentGraphicObjectRotating;
  internal Canvas AttachmentAxesZoomPanelRotating;
  internal Canvas AttachmentAxesFrameIndicationRotating;
  internal Canvas AttachmentAxesDiagramIndicationRotating;
  internal Path AttachmentXAxisBackgroundRotating;
  internal Path AttachmentYAxisBackgroundRotating;
  internal Ellipse MiniCableBackgroundEllipseBackRotating;
  internal Ellipse MiniCableHolderBackRotating;
  internal Path MiniCableShapeFillerRotating;
  internal Path MiniCableRightEdgeRotating;
  internal Path MiniCableLeftEdgeRotating;
  internal Ellipse MiniCableHolderFrontRotating;
  internal Ellipse MiniCableBackgroundEllipseFrontRotating;
  internal Ellipse MiniCableForegroundEllipseRotating;
  internal Canvas AttachmentZAxisEllipticalArrowRotating;
  internal Ellipse MiniCableForegroundEllipticalArrowRotating;
  internal Path MiniCableForegroundEllipticalArrowStartTipRotating;
  internal Path MiniCableForegroundEllipticalArrowEndTipRotating;
  internal Canvas AttachmentXAxisForegroundRotating;
  internal Canvas AttachmentXAxisEllipticalArrowRotating;
  internal Canvas AttachmentYAxisForegroundRotating;
  internal Canvas AttachmentYAxisEllipticalArrowRotating;
  internal Canvas AttachmentXArrowRotating;
  internal TextBlock AttachmentXAxisLabelRotating;
  internal Canvas AttachmentYArrowRotating;
  internal TextBlock AttachmentYAxisLabelRotating;
  internal Canvas AttachmentZArrowRotating;
  internal Canvas HitBoxesRotating;
  internal Canvas DistanceFromStartHitBoxRotating;
  internal Canvas AttachmentFrameHitBoxRotating;
  internal Path AttachmentFrameZoomHitBoxRotating;
  internal Canvas RotationAxisHitBoxRotating;
  internal Rectangle RotationAxisZoomHitBoxRotating;
  internal StackPanel RotatingAttachmentPanel;
  internal Grid RotatingAttachmentGrid;
  internal TextBlock RotatingLocationLabel;
  internal ComboBox RotatingLocationCombo;
  internal TextBlock RotatingAttachmentFrameLabel;
  internal TxObjEditBoxControl RotatingAttachmentFrameBoxCtrl;
  internal TextBlock RotatingDistanceFromStartLabel;
  internal TxNumericEditBoxControl RotatingDistanceFromStartTxNumericEditBox;
  internal TextBlock RotatingRotationAxisLabel;
  internal ComboBox RotatingRotationAxisCombo;
  private bool _contentLoaded;

  public event ParameterChangeEventHandler ParameterChanged;

  public new string Name { get; set; }

  public CApFlexParameterController ParameterController { get; set; }

  public CApCableAttachmentStatusAnalysis CableAttachmentStatusAnalysis { get; set; }

  public ICApFLEXCableAttributeViewModel AttributeViewModel { get; private set; }

  public CApFLEXCableAttachmentViewModel AttachmentViewModel { get; private set; }

  public CApFLEXAttachmentEditorViewModel EditorViewModel
  {
    get => (CApFLEXAttachmentEditorViewModel) this.RotatingAttachmentEditorViewModel;
  }

  public CApFLEXRotatingAttachmentEditorViewModel RotatingAttachmentEditorViewModel { get; }

  public List<Storyboard> AttachmentStoryboards
  {
    get
    {
      return new List<Storyboard>(5)
      {
        this.CanvasRotatingAttachment.FindResource((object) "PreviewRotatingAttachment") as Storyboard,
        this.CanvasRotatingAttachment.FindResource((object) "PreviewRotatingAttachmentZoomOnX") as Storyboard,
        this.CanvasRotatingAttachment.FindResource((object) "PreviewRotatingAttachmentZoomOnY") as Storyboard,
        this.CanvasRotatingAttachment.FindResource((object) "PreviewRotatingAttachmentZoomOnZ") as Storyboard,
        this.CanvasRotatingAttachment.FindResource((object) "PreviewRotatingAttachmentZoomOnAll") as Storyboard
      };
    }
  }

  public Storyboard ActiveAttachmentStoryboard
  {
    get
    {
      Storyboard resource = this.CanvasRotatingAttachment.FindResource((object) "PreviewRotatingAttachment") as Storyboard;
      if (this.IsZoomPanelVisible)
      {
        string resourceKey;
        switch (this.AttachmentViewModel.RotatingRotationAxis)
        {
          case CApFLEXRotatingAttachmentRotationAxis.X:
            resourceKey = "PreviewRotatingAttachmentZoomOnX";
            break;
          case CApFLEXRotatingAttachmentRotationAxis.Y:
            resourceKey = "PreviewRotatingAttachmentZoomOnY";
            break;
          case CApFLEXRotatingAttachmentRotationAxis.Z:
            resourceKey = "PreviewRotatingAttachmentZoomOnZ";
            break;
          case CApFLEXRotatingAttachmentRotationAxis.All:
            resourceKey = "PreviewRotatingAttachmentZoomOnAll";
            break;
          default:
            throw new NotImplementedException();
        }
        resource = this.CanvasRotatingAttachment.FindResource((object) resourceKey) as Storyboard;
      }
      return resource;
    }
  }

  public Shape SimulatedShape => (Shape) this.CableSimulatedSection2Rotating;

  private CApCableAttachmentFrameController AttachmentFrameController { get; set; }

  private CApCableAttachmentFrameUpdater AttachmentFrameUpdater { get; set; }

  private CApCableAttachmentLengthFromStartUpdater LengthFromStartUpdater { get; set; }

  private TxNumericEditBoxControl LastFocusedNumericBox { get; set; }

  private ComboBox LastFocusedComboBox { get; set; }

  public TxObjEditBoxControl FrameEditBoxCtrlAttachment => this.RotatingAttachmentFrameBoxCtrl;

  private bool IsControlLoading => this.EditorViewModel.IsControlLoading;

  private bool IsControlActivated => this.EditorViewModel.IsControlActivated;

  private bool IsZoomPanelVisible
  {
    get => this.RotatingAttachmentEditorViewModel.IsZoomPanelVisible;
    set => this.RotatingAttachmentEditorViewModel.IsZoomPanelVisible = value;
  }

  public CApCableRotatingAttachmentControl()
  {
    this.RotatingAttachmentEditorViewModel = new CApFLEXRotatingAttachmentEditorViewModel();
  }

  public void InitControl(
    ICApFLEXCableAttributeViewModel attributeViewModel,
    CApFLEXCableAttachmentViewModel attachmentViewModel,
    CApFLEXFrameValidator frameValidator,
    bool isCreationMode,
    CApFlexParameterController parameterController,
    CApCableAttachmentStatusAnalysis cableAttachmentStatusAnalysis,
    CApCableAttachmentFrameController attachmentFrameController)
  {
    this.AttributeViewModel = attributeViewModel;
    this.AttachmentViewModel = attachmentViewModel;
    this.ParameterController = parameterController;
    this.CableAttachmentStatusAnalysis = cableAttachmentStatusAnalysis;
    this.AttachmentFrameController = attachmentFrameController;
    this.InitializeComponent();
    this.RegisterNumericalControlEvents();
    this.InitFixedFrameEditBox(frameValidator, isCreationMode);
    this.InitLocationCombo();
    this.InitRotationAxisCombo();
    this.UpdateLocationCombo(this.AttachmentViewModel.Location);
    this.UpdateRotationAxisCombo(this.AttachmentViewModel.RotatingRotationAxis);
    this.UpdateLabelText();
    this.SetBindings();
  }

  private void InitFixedFrameEditBox(CApFLEXFrameValidator frameValidator, bool isCreationMode)
  {
    this.RotatingAttachmentFrameBoxCtrl.ValidatorType = (TxValidatorType) 6;
    this.RotatingAttachmentFrameBoxCtrl.SetValidator((ITxValidator) frameValidator);
    this.RotatingAttachmentFrameBoxCtrl.Picked += new TxObjEditBoxCtrl_PickedEventHandler(this.AttachmentFrameEditBoxCtrl_Picked);
    if (!isCreationMode)
      this.RotatingAttachmentFrameBoxCtrl.Object = (ITxObject) this.AttachmentViewModel.FixedFrame;
    ((UIElement) this.RotatingAttachmentFrameBoxCtrl).KeyUp += new KeyEventHandler(this.RotatingAttachmentFrame_KeyUp);
    this.AttachmentFrameUpdater = new CApCableAttachmentFrameUpdater(this.RotatingAttachmentFrameBoxCtrl, this.AttachmentFrameController, this.AttributeViewModel, this.AttachmentViewModel);
    this.LengthFromStartUpdater = new CApCableAttachmentLengthFromStartUpdater(this.RotatingDistanceFromStartTxNumericEditBox, this.AttributeViewModel, this.AttachmentViewModel);
  }

  private void InitLocationCombo()
  {
    ComboBox rotatingLocationCombo = this.RotatingLocationCombo;
    ObservableCollection<CApCableAttachmentLocationComboBoxItem> observableCollection = new ObservableCollection<CApCableAttachmentLocationComboBoxItem>();
    observableCollection.Add(new CApCableAttachmentLocationComboBoxItem(CApFLEXStringTable.AttachmentLocationAlongCable, CApFLEXAttachmentLocation.AlongCable));
    observableCollection.Add(new CApCableAttachmentLocationComboBoxItem(CApFLEXStringTable.AttachmentLocationStart, CApFLEXAttachmentLocation.Start));
    observableCollection.Add(new CApCableAttachmentLocationComboBoxItem(CApFLEXStringTable.AttachmentLocationEnd, CApFLEXAttachmentLocation.End));
    rotatingLocationCombo.ItemsSource = (IEnumerable) observableCollection;
  }

  private void InitRotationAxisCombo()
  {
    ComboBox rotationAxisCombo = this.RotatingRotationAxisCombo;
    ObservableCollection<CApCableRotatingAttachmentRotationAxisComboBoxItem> observableCollection = new ObservableCollection<CApCableRotatingAttachmentRotationAxisComboBoxItem>();
    observableCollection.Add(new CApCableRotatingAttachmentRotationAxisComboBoxItem(CApFLEXStringTable.AttachmentRotationAxisX, CApFLEXRotatingAttachmentRotationAxis.X));
    observableCollection.Add(new CApCableRotatingAttachmentRotationAxisComboBoxItem(CApFLEXStringTable.AttachmentRotationAxisY, CApFLEXRotatingAttachmentRotationAxis.Y));
    observableCollection.Add(new CApCableRotatingAttachmentRotationAxisComboBoxItem(CApFLEXStringTable.AttachmentRotationAxisZ, CApFLEXRotatingAttachmentRotationAxis.Z));
    observableCollection.Add(new CApCableRotatingAttachmentRotationAxisComboBoxItem(CApFLEXStringTable.AttachmentRotationAxisAll, CApFLEXRotatingAttachmentRotationAxis.All));
    rotationAxisCombo.ItemsSource = (IEnumerable) observableCollection;
  }

  public void SetUpStoryboardsParameters()
  {
    List<Storyboard> attachmentStoryboards = this.AttachmentStoryboards;
    for (int index = 0; index < attachmentStoryboards.Count; ++index)
    {
      attachmentStoryboards[index].SpeedRatio = 1.0;
      attachmentStoryboards[index].AutoReverse = index > 0 && index < 4;
    }
  }

  public void UpdateLabelText() => this.UpdateLinearUnitText();

  public void UpdateLinearUnitText()
  {
    this.RotatingDistanceFromStartLabel.Text = CApFLEXStringTable.AttachmentLengthLabel + CApCableUtility.LinearUnitLabelText();
  }

  public void UpdateAttachmentCtrlBox()
  {
    this.RotatingAttachmentFrameBoxCtrl.Text = "";
    this.RotatingAttachmentFrameBoxCtrl.Object = (ITxObject) this.AttachmentViewModel.FixedFrame;
    if (this.AttachmentViewModel.FixedFrame != null)
      return;
    this.RotatingAttachmentFrameBoxCtrl.Focus();
  }

  private void UpdateLocationCombo(CApFLEXAttachmentLocation location)
  {
    bool flag = false;
    for (int index = 0; !flag && index < this.RotatingLocationCombo.Items.Count; ++index)
    {
      if (this.RotatingLocationCombo.Items[index] is CApCableAttachmentLocationComboBoxItem locationComboBoxItem && locationComboBoxItem.Location == location)
      {
        this.RotatingLocationCombo.SelectedItem = (object) locationComboBoxItem;
        flag = true;
      }
    }
  }

  private void UpdateRotationAxisCombo(CApFLEXRotatingAttachmentRotationAxis rotationAxis)
  {
    bool flag = false;
    for (int index = 0; !flag && index < this.RotatingRotationAxisCombo.Items.Count; ++index)
    {
      if (this.RotatingRotationAxisCombo.Items[index] is CApCableRotatingAttachmentRotationAxisComboBoxItem axisComboBoxItem && axisComboBoxItem.RotationAxis == rotationAxis)
      {
        this.RotatingRotationAxisCombo.SelectedItem = (object) axisComboBoxItem;
        flag = true;
      }
    }
  }

  private void RegisterNumericalControlEvents()
  {
    this.RotatingDistanceFromStartTxNumericEditBox.TentativeValueChanged += new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.RotatingDistanceFromStartTxNumericEditBox_TentativeValueChanged);
  }

  private void UnregisterNumericalControlEvents()
  {
    this.RotatingDistanceFromStartTxNumericEditBox.TentativeValueChanged -= new TxNumericEditBoxCtrl_TentativeValueChangedEventHandler(this.RotatingDistanceFromStartTxNumericEditBox_TentativeValueChanged);
  }

  public void UpdateAttachmentParametersWithParameters()
  {
    if (!this.IsControlActivated)
      return;
    this.AttachmentViewModel.Location = this.ParameterController.AttachmentLocation;
    if (this.AttachmentViewModel.Location == CApFLEXAttachmentLocation.AlongCable)
      this.AttachmentViewModel.FixedFrame = (ITxLocatableObject) null;
    this.AttachmentViewModel.SecondaryFixedFrame = (ITxLocatableObject) null;
    this.AttachmentViewModel.LengthFromStart = this.AttributeViewModel.Length * 0.5;
    this.AttachmentViewModel.RotatingRotationAxis = this.ParameterController.RotatingRotationAxis;
    this.UpdateLocationCombo(this.AttachmentViewModel.Location);
    this.UpdateRotationAxisCombo(this.AttachmentViewModel.RotatingRotationAxis);
  }

  public void UpdateAttachmentParametersWithAttachment(CApFLEXAttachment attachment)
  {
    if (!this.IsControlActivated)
      return;
    this.AttachmentViewModel.AttachmentType = attachment.AttachmentType;
    this.AttachmentViewModel.Location = attachment.Location;
    this.AttachmentViewModel.FixedFrame = attachment.FixedFrame;
    this.AttachmentViewModel.SecondaryFixedFrame = (ITxLocatableObject) null;
    this.AttachmentViewModel.LengthFromStart = attachment.LengthFromStart;
    this.AttachmentViewModel.RotatingRotationAxis = (attachment as CApFLEXRotatingAttachment).RotationAxis;
    this.UpdateLocationCombo(this.AttachmentViewModel.Location);
    this.UpdateRotationAxisCombo(this.AttachmentViewModel.RotatingRotationAxis);
  }

  public void SetDefaultFocus()
  {
    if (!this.IsControlActivated)
      return;
    if (this.AttachmentViewModel.Location == CApFLEXAttachmentLocation.AlongCable)
      this.Dispatcher.BeginInvoke(DispatcherPriority.Render, (Delegate) (() => this.RotatingAttachmentFrameBoxCtrl.Focus()));
    else
      this.RotatingRotationAxisCombo.Focus();
    this.DoSetDefaultFocus();
  }

  private void DoSetDefaultFocus()
  {
    if (this.AttachmentViewModel.Location == CApFLEXAttachmentLocation.AlongCable)
    {
      if (this.RotatingAttachmentFrameBoxCtrl.Text != "")
        CApCableUtility.HighlightObject((ITxDisplayableObject) (this.AttachmentViewModel.FixedFrame as TxFrame));
      this.IsZoomPanelVisible = true;
      this.AttachmentViewModel.AttachmentFrameSelected = true;
    }
    else
      this.AttachmentViewModel.RotationAxisSelected = true;
  }

  private void SetBindings()
  {
    this.SetZoomPanelToVisibilityBindings();
    this.SetPreviewToVisibilityBindings();
    this.SetRotationAxisToVisibilityBindings();
    this.SetRotationAxisToBrushBindings();
  }

  private void SetZoomPanelToVisibilityBindings()
  {
    Binding binding = new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("EditorViewModel.IsZoomPanelVisible", Array.Empty<object>()),
      Converter = (IValueConverter) new BooleanToDiagramVisibilityConverter()
    };
    this.AttachmentFrameZoomHitBoxRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding);
    this.RotationAxisZoomHitBoxRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding);
    this.BackgroundLayerRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding);
    this.AttachmentAxesZoomPanelRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding);
    this.AttachmentAxesFrameIndicationRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding);
    this.AttachmentAxesDiagramIndicationRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding);
  }

  private void SetPreviewToVisibilityBindings()
  {
    Binding binding1 = new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("EditorViewModel.IsPreviewIdle", Array.Empty<object>()),
      Converter = (IValueConverter) new BooleanToDiagramVisibilityConverter()
    };
    this.AttachmentZArrowRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding1);
    this.HitBoxesRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding1);
    MultiBinding binding2 = new MultiBinding()
    {
      Converter = (IMultiValueConverter) new MultipleBooleanToDiagramVisibilityConverter()
    };
    binding2.Bindings.Add((BindingBase) new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("RotatingAttachmentEditorViewModel.IsZoomPanelVisible", Array.Empty<object>())
    });
    binding2.Bindings.Add((BindingBase) new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("EditorViewModel.IsPreviewIdle", Array.Empty<object>())
    });
    this.StartFramePointerRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.StartFrameAxesRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.StartFrameLabelRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.EndFramePointerRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.EndFrameAxesRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.EndFrameLabelRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.AttachmentFramePointerRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.AttachmentFrameAxesRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.AttachmentFrameLabelRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.DistanceFromStartPathRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.DistanceFromStartPointerRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.DistanceFromStartLabelRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    this.DistanceFromStartFocusRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding2);
    MultiBinding binding3 = new MultiBinding()
    {
      Converter = (IMultiValueConverter) new MultipleBooleanToDiagramVisibilityReverseConverter()
    };
    binding3.Bindings.Add((BindingBase) new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("RotatingAttachmentEditorViewModel.IsZoomPanelVisible", Array.Empty<object>())
    });
    binding3.Bindings.Add((BindingBase) new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("EditorViewModel.IsPreviewIdle", Array.Empty<object>())
    });
    this.RotationArrowRotating.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding3);
  }

  private void SetRotationAxisToVisibilityBindings()
  {
    RotatingAttachmentRotationAxisToVisibilityConverter converter1 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter1.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, Visibility.Visible);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentYAxisLineRotating, converter1);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentYAxisArrowRotating, converter1);
    RotatingAttachmentRotationAxisToVisibilityConverter converter2 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter2.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, Visibility.Visible);
    converter2.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    converter2.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, PreviewVisibility.DuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentXAxisForegroundRotating, converter2);
    RotatingAttachmentRotationAxisToVisibilityConverter converter3 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter3.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, Visibility.Visible);
    converter3.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentXAxisBackgroundRotating, converter3);
    RotatingAttachmentRotationAxisToVisibilityConverter converter4 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter4.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, Visibility.Visible);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentXAxisLineRotating, converter4);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentXAxisArrowRotating, converter4);
    RotatingAttachmentRotationAxisToVisibilityConverter converter5 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter5.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, Visibility.Visible);
    converter5.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    converter5.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, PreviewVisibility.DuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentYAxisForegroundRotating, converter5);
    RotatingAttachmentRotationAxisToVisibilityConverter converter6 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter6.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, Visibility.Visible);
    converter6.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentYAxisBackgroundRotating, converter6);
    RotatingAttachmentRotationAxisToVisibilityConverter converter7 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter7.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    converter7.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, Visibility.Visible);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentAnyAxisLineRotating, converter7);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentAnyAxisArrowRotating, converter7);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentZAxisEllipticalArrowRotating, converter7);
    RotatingAttachmentRotationAxisToVisibilityConverter converter8 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter8.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, Visibility.Visible);
    converter8.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    converter8.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, PreviewVisibility.NotDuringPreview);
    converter8.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, PreviewVisibility.NotDuringPreview);
    converter8.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, PreviewVisibility.NotDuringPreview);
    converter8.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, PreviewVisibility.NotDuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentYAxisLabelRotating, converter8);
    RotatingAttachmentRotationAxisToVisibilityConverter converter9 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter9.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, Visibility.Visible);
    converter9.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    converter9.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, PreviewVisibility.NotDuringPreview);
    converter9.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, PreviewVisibility.NotDuringPreview);
    converter9.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, PreviewVisibility.NotDuringPreview);
    converter9.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, PreviewVisibility.NotDuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentXAxisLabelRotating, converter9);
    RotatingAttachmentRotationAxisToVisibilityConverter converter10 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter10.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, Visibility.Visible);
    converter10.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    converter10.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, Visibility.Visible);
    converter10.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, PreviewVisibility.NotDuringPreview);
    converter10.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, PreviewVisibility.NotDuringPreview);
    converter10.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, PreviewVisibility.NotDuringPreview);
    converter10.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, PreviewVisibility.NotDuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentYArrowRotating, converter10);
    RotatingAttachmentRotationAxisToVisibilityConverter converter11 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter11.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, Visibility.Visible);
    converter11.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, Visibility.Visible);
    converter11.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, Visibility.Visible);
    converter11.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, PreviewVisibility.NotDuringPreview);
    converter11.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, PreviewVisibility.NotDuringPreview);
    converter11.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, PreviewVisibility.NotDuringPreview);
    converter11.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, PreviewVisibility.NotDuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentXArrowRotating, converter11);
    RotatingAttachmentRotationAxisToVisibilityConverter converter12 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter12.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, Visibility.Visible);
    converter12.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, Visibility.Visible);
    converter12.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, PreviewVisibility.NotDuringPreview);
    converter12.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, PreviewVisibility.NotDuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentXAxisEllipticalArrowRotating, converter12);
    RotatingAttachmentRotationAxisToVisibilityConverter converter13 = new RotatingAttachmentRotationAxisToVisibilityConverter();
    converter13.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, Visibility.Visible);
    converter13.AssignRegularVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, Visibility.Visible);
    converter13.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, PreviewVisibility.NotDuringPreview);
    converter13.AssignPreviewVisibilityToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, PreviewVisibility.NotDuringPreview);
    this.BindElementVisibilityToRotationAxis((FrameworkElement) this.AttachmentYAxisEllipticalArrowRotating, converter13);
  }

  private void SetRotationAxisToBrushBindings()
  {
    RotatingAttachmentRotationAxisToBrushConverter converter = new RotatingAttachmentRotationAxisToBrushConverter();
    converter.AssignBrushToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.X, (Brush) this.FindResource((object) "PLBloodRed6"));
    converter.AssignBrushToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Y, (Brush) this.FindResource((object) "PLGreen5"));
    converter.AssignBrushToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.Z, (Brush) this.FindResource((object) "PureBlack5"));
    converter.AssignBrushToRotationAxis(CApFLEXRotatingAttachmentRotationAxis.All, (Brush) this.FindResource((object) "PureBlack5"));
    this.BindElementStrokeToRotationAxis((FrameworkElement) this.RotationArrowLeftLineRotating, converter);
    this.BindElementStrokeToRotationAxis((FrameworkElement) this.RotationArrowLeftCapRotating, converter);
    this.BindElementStrokeToRotationAxis((FrameworkElement) this.RotationArrowRightLineRotating, converter);
    this.BindElementStrokeToRotationAxis((FrameworkElement) this.RotationArrowRightCapRotating, converter);
  }

  private void BindElementVisibilityToRotationAxis(
    FrameworkElement element,
    RotatingAttachmentRotationAxisToVisibilityConverter converter)
  {
    MultiBinding binding = new MultiBinding()
    {
      Converter = (IMultiValueConverter) converter
    };
    binding.Bindings.Add((BindingBase) new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("AttachmentViewModel.RotatingRotationAxis", Array.Empty<object>())
    });
    binding.Bindings.Add((BindingBase) new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("EditorViewModel.IsPreviewRunning", Array.Empty<object>())
    });
    element.SetBinding(UIElement.VisibilityProperty, (BindingBase) binding);
  }

  private void BindElementStrokeToRotationAxis(
    FrameworkElement element,
    RotatingAttachmentRotationAxisToBrushConverter converter)
  {
    element.SetBinding(Shape.StrokeProperty, (BindingBase) new Binding()
    {
      Source = (object) this,
      Path = new PropertyPath("AttachmentViewModel.RotatingRotationAxis", Array.Empty<object>()),
      Converter = (IValueConverter) converter
    });
  }

  public void SetEnabledAllParametersControls(bool isEnabled)
  {
    if (!isEnabled)
    {
      this.LastFocusedNumericBox = this.GetCurrentlyFocusedNumericBox();
      this.LastFocusedComboBox = this.GetCurrentlyFocusedComboBox();
    }
    this.RotatingAttachmentPanel.IsEnabled = isEnabled;
    if (!isEnabled)
      return;
    if (this.LastFocusedNumericBox != null)
    {
      ((UIElement) this.LastFocusedNumericBox).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
      this.LastFocusedNumericBox = (TxNumericEditBoxControl) null;
    }
    if (this.LastFocusedComboBox == null)
      return;
    this.LastFocusedComboBox.Focus();
    this.LastFocusedComboBox = (ComboBox) null;
  }

  private TxNumericEditBoxControl GetCurrentlyFocusedNumericBox()
  {
    TxNumericEditBoxControl focusedNumericBox = (TxNumericEditBoxControl) null;
    if (this.AttachmentViewModel.DistanceFromStartSelected)
      focusedNumericBox = this.RotatingDistanceFromStartTxNumericEditBox;
    return focusedNumericBox;
  }

  private ComboBox GetCurrentlyFocusedComboBox()
  {
    ComboBox currentlyFocusedComboBox = (ComboBox) null;
    if (this.AttachmentViewModel.LocationSelected)
      currentlyFocusedComboBox = this.RotatingLocationCombo;
    else if (this.AttachmentViewModel.RotationAxisSelected)
      currentlyFocusedComboBox = this.RotatingRotationAxisCombo;
    return currentlyFocusedComboBox;
  }

  public void DidDialogClose()
  {
    this.UnregisterNumericalControlEvents();
    this.AttachmentFrameUpdater.UnregisterEvents();
    this.LengthFromStartUpdater.UnregisterEvents();
    this.RotatingAttachmentFrameBoxCtrl.Picked -= new TxObjEditBoxCtrl_PickedEventHandler(this.AttachmentFrameEditBoxCtrl_Picked);
    ((UIElement) this.RotatingAttachmentFrameBoxCtrl).KeyUp -= new KeyEventHandler(this.RotatingAttachmentFrame_KeyUp);
    this.RotatingDistanceFromStartTxNumericEditBox = (TxNumericEditBoxControl) null;
  }

  private void AttachmentFrame_DiagramFocus(object sender, MouseButtonEventArgs e)
  {
    this.RotatingAttachmentFrameBoxCtrl.Focus();
  }

  private void AttachmentFrame_GotFocus(object sender, RoutedEventArgs e)
  {
    this.DoSetDefaultFocus();
  }

  private void AttachmentFrame_LostFocus(object sender, RoutedEventArgs e)
  {
    CApCableUtility.UnHighlightObject((ITxDisplayableObject) (this.AttachmentViewModel.FixedFrame as TxFrame));
    this.IsZoomPanelVisible = false;
    this.AttachmentViewModel.AttachmentFrameSelected = false;
  }

  private void AttachmentFrame_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
  {
  }

  private void DistanceFromStart_DiagramFocus(object sender, MouseButtonEventArgs e)
  {
    ((UIElement) this.RotatingDistanceFromStartTxNumericEditBox).MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
  }

  private void DistanceFromStart_GotFocus(object sender, RoutedEventArgs e)
  {
    this.IsZoomPanelVisible = false;
    this.AttachmentViewModel.DistanceFromStartSelected = true;
  }

  private void DistanceFromStart_LostFocus(object sender, RoutedEventArgs e)
  {
    this.IsZoomPanelVisible = false;
    this.AttachmentViewModel.DistanceFromStartSelected = false;
  }

  private void RotationAxis_DiagramFocus(object sender, MouseButtonEventArgs e)
  {
    this.RotatingRotationAxisCombo.Focus();
  }

  private void Location_GotFocus(object sender, RoutedEventArgs e)
  {
    this.IsZoomPanelVisible = false;
    this.AttachmentViewModel.LocationSelected = true;
  }

  private void Location_LostFocus(object sender, RoutedEventArgs e)
  {
    this.IsZoomPanelVisible = false;
    this.AttachmentViewModel.LocationSelected = false;
  }

  private void RotationAxis_GotFocus(object sender, RoutedEventArgs e)
  {
    this.IsZoomPanelVisible = true;
    this.AttachmentViewModel.RotationAxisSelected = true;
  }

  private void RotationAxis_LostFocus(object sender, RoutedEventArgs e)
  {
    this.IsZoomPanelVisible = false;
    this.AttachmentViewModel.RotationAxisSelected = false;
  }

  private void RotatingDistanceFromStartTxNumericEditBox_TentativeValueChanged(
    object sender,
    TxNumericEditBoxCtrl_TentativeValueChangedEventArgs args)
  {
    if (this.IsControlLoading || !this.IsControlActivated)
      return;
    this.LengthFromStartUpdater.SetLengthFromStart(args.TentativeValue * TxApplication.Options.Units.LinearMultiplier);
    this.ParameterChanged();
  }

  private void RotatingLocation_SelectionChanged(object sender, SelectionChangedEventArgs e)
  {
    if (this.RotatingLocationCombo.SelectedItem != null)
    {
      CApFLEXAttachmentLocation location = (this.RotatingLocationCombo.SelectedItem as CApCableAttachmentLocationComboBoxItem).Location;
      this.AttachmentViewModel.Location = location;
      if (location != CApFLEXAttachmentLocation.AlongCable)
        return;
      this.SetDefaultFocus();
    }
    else
      this.UpdateLocationCombo(this.AttachmentViewModel.Location);
  }

  private void RotatingRotationAxis_SelectionChanged(object sender, SelectionChangedEventArgs e)
  {
    if (this.RotatingRotationAxisCombo.SelectedItem != null)
      this.AttachmentViewModel.RotatingRotationAxis = (this.RotatingRotationAxisCombo.SelectedItem as CApCableRotatingAttachmentRotationAxisComboBoxItem).RotationAxis;
    else
      this.UpdateRotationAxisCombo(this.AttachmentViewModel.RotatingRotationAxis);
  }

  private void AttachmentFrameEditBoxCtrl_Picked(
    object sender,
    TxObjEditBoxCtrl_PickedEventArgs args)
  {
    this.AttachmentFrameUpdater.SetAttachmentFrame(this.RotatingAttachmentFrameBoxCtrl.Object as ITxLocatableObject);
  }

  private void RotatingAttachmentFrame_KeyUp(object sender, KeyEventArgs e)
  {
    if (e.Key != Key.Back && e.Key != Key.Delete)
      return;
    this.AttachmentFrameUpdater.UnsetAttachmentFrame();
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  public void InitializeComponent()
  {
    if (this._contentLoaded)
      return;
    this._contentLoaded = true;
    Application.LoadComponent((object) this, new Uri("/DnProcessSimulateCommands;component/flexibles/attachmentcontrols/capcablerotatingattachmentcontrol.xaml", UriKind.Relative));
  }

  [DebuggerNonUserCode]
  [GeneratedCode("PresentationBuildTasks", "4.0.0.0")]
  [EditorBrowsable(EditorBrowsableState.Never)]
  void IComponentConnector.Connect(int connectionId, object target)
  {
    switch (connectionId)
    {
      case 1:
        this.RotatingAttachmentBorder = (Border) target;
        break;
      case 2:
        this.CanvasRotatingAttachment = (Canvas) target;
        break;
      case 3:
        this.BackgroundLayerRotating = (Path) target;
        break;
      case 4:
        this.EndFrameAxesRotating = (Canvas) target;
        break;
      case 5:
        this.EndFramePointerRotating = (Canvas) target;
        break;
      case 6:
        this.EndFrameLabelRotating = (TextBlock) target;
        break;
      case 7:
        this.StartFrameAxesRotating = (Canvas) target;
        break;
      case 8:
        this.StartFramePointerRotating = (Canvas) target;
        break;
      case 9:
        this.StartFrameLabelRotating = (TextBlock) target;
        break;
      case 10:
        this.AttachmentFramePointerRotating = (Canvas) target;
        break;
      case 11:
        this.AttachmentFrameLabelRotating = (TextBlock) target;
        break;
      case 12:
        this.AttachmentFrameAxesRotating = (Canvas) target;
        break;
      case 13:
        this.AttachmentXAxisLineRotating = (Path) target;
        break;
      case 14:
        this.AttachmentXAxisArrowRotating = (Path) target;
        break;
      case 15:
        this.AttachmentYAxisLineRotating = (Path) target;
        break;
      case 16 /*0x10*/:
        this.AttachmentYAxisArrowRotating = (Path) target;
        break;
      case 17:
        this.AttachmentAnyAxisLineRotating = (Path) target;
        break;
      case 18:
        this.AttachmentAnyAxisArrowRotating = (Path) target;
        break;
      case 19:
        this.CableSimulatedSection1Rotating = (Path) target;
        break;
      case 20:
        this.CableSimulatedSection2Rotating = (Path) target;
        break;
      case 21:
        this.RotationArrowRotating = (Grid) target;
        break;
      case 22:
        this.RotationArrowLeftLineRotating = (Path) target;
        break;
      case 23:
        this.RotationArrowLeftCapRotating = (Path) target;
        break;
      case 24:
        this.RotationArrowRightLineRotating = (Path) target;
        break;
      case 25:
        this.RotationArrowRightCapRotating = (Path) target;
        break;
      case 26:
        this.DistanceFromStartFocusRotating = (Path) target;
        break;
      case 27:
        this.DistanceFromStartPathRotating = (Path) target;
        break;
      case 28:
        this.DistanceFromStartPointerRotating = (Canvas) target;
        break;
      case 29:
        this.DistanceFromStartLabelRotating = (TextBlock) target;
        break;
      case 30:
        this.AttachmentGraphicObjectRotating = (Rectangle) target;
        break;
      case 31 /*0x1F*/:
        this.AttachmentAxesZoomPanelRotating = (Canvas) target;
        break;
      case 32 /*0x20*/:
        this.AttachmentAxesFrameIndicationRotating = (Canvas) target;
        break;
      case 33:
        this.AttachmentAxesDiagramIndicationRotating = (Canvas) target;
        break;
      case 34:
        this.AttachmentXAxisBackgroundRotating = (Path) target;
        break;
      case 35:
        this.AttachmentYAxisBackgroundRotating = (Path) target;
        break;
      case 36:
        this.MiniCableBackgroundEllipseBackRotating = (Ellipse) target;
        break;
      case 37:
        this.MiniCableHolderBackRotating = (Ellipse) target;
        break;
      case 38:
        this.MiniCableShapeFillerRotating = (Path) target;
        break;
      case 39:
        this.MiniCableRightEdgeRotating = (Path) target;
        break;
      case 40:
        this.MiniCableLeftEdgeRotating = (Path) target;
        break;
      case 41:
        this.MiniCableHolderFrontRotating = (Ellipse) target;
        break;
      case 42:
        this.MiniCableBackgroundEllipseFrontRotating = (Ellipse) target;
        break;
      case 43:
        this.MiniCableForegroundEllipseRotating = (Ellipse) target;
        break;
      case 44:
        this.AttachmentZAxisEllipticalArrowRotating = (Canvas) target;
        break;
      case 45:
        this.MiniCableForegroundEllipticalArrowRotating = (Ellipse) target;
        break;
      case 46:
        this.MiniCableForegroundEllipticalArrowStartTipRotating = (Path) target;
        break;
      case 47:
        this.MiniCableForegroundEllipticalArrowEndTipRotating = (Path) target;
        break;
      case 48 /*0x30*/:
        this.AttachmentXAxisForegroundRotating = (Canvas) target;
        break;
      case 49:
        this.AttachmentXAxisEllipticalArrowRotating = (Canvas) target;
        break;
      case 50:
        this.AttachmentYAxisForegroundRotating = (Canvas) target;
        break;
      case 51:
        this.AttachmentYAxisEllipticalArrowRotating = (Canvas) target;
        break;
      case 52:
        this.AttachmentXArrowRotating = (Canvas) target;
        break;
      case 53:
        this.AttachmentXAxisLabelRotating = (TextBlock) target;
        break;
      case 54:
        this.AttachmentYArrowRotating = (Canvas) target;
        break;
      case 55:
        this.AttachmentYAxisLabelRotating = (TextBlock) target;
        break;
      case 56:
        this.AttachmentZArrowRotating = (Canvas) target;
        break;
      case 57:
        this.HitBoxesRotating = (Canvas) target;
        break;
      case 58:
        this.DistanceFromStartHitBoxRotating = (Canvas) target;
        this.DistanceFromStartHitBoxRotating.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(this.DistanceFromStart_DiagramFocus);
        break;
      case 59:
        this.AttachmentFrameHitBoxRotating = (Canvas) target;
        this.AttachmentFrameHitBoxRotating.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(this.AttachmentFrame_DiagramFocus);
        break;
      case 60:
        this.AttachmentFrameZoomHitBoxRotating = (Path) target;
        break;
      case 61:
        this.RotationAxisHitBoxRotating = (Canvas) target;
        this.RotationAxisHitBoxRotating.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(this.RotationAxis_DiagramFocus);
        break;
      case 62:
        this.RotationAxisZoomHitBoxRotating = (Rectangle) target;
        break;
      case 63 /*0x3F*/:
        this.RotatingAttachmentPanel = (StackPanel) target;
        break;
      case 64 /*0x40*/:
        this.RotatingAttachmentGrid = (Grid) target;
        break;
      case 65:
        this.RotatingLocationLabel = (TextBlock) target;
        break;
      case 66:
        this.RotatingLocationCombo = (ComboBox) target;
        this.RotatingLocationCombo.SelectionChanged += new SelectionChangedEventHandler(this.RotatingLocation_SelectionChanged);
        this.RotatingLocationCombo.GotFocus += new RoutedEventHandler(this.Location_GotFocus);
        this.RotatingLocationCombo.LostFocus += new RoutedEventHandler(this.Location_LostFocus);
        break;
      case 67:
        this.RotatingAttachmentFrameLabel = (TextBlock) target;
        break;
      case 68:
        this.RotatingAttachmentFrameBoxCtrl = (TxObjEditBoxControl) target;
        ((UIElement) this.RotatingAttachmentFrameBoxCtrl).GotFocus += new RoutedEventHandler(this.AttachmentFrame_GotFocus);
        ((UIElement) this.RotatingAttachmentFrameBoxCtrl).LostFocus += new RoutedEventHandler(this.AttachmentFrame_LostFocus);
        ((UIElement) this.RotatingAttachmentFrameBoxCtrl).IsEnabledChanged += new DependencyPropertyChangedEventHandler(this.AttachmentFrame_IsEnabledChanged);
        break;
      case 69:
        this.RotatingDistanceFromStartLabel = (TextBlock) target;
        break;
      case 70:
        this.RotatingDistanceFromStartTxNumericEditBox = (TxNumericEditBoxControl) target;
        ((UIElement) this.RotatingDistanceFromStartTxNumericEditBox).GotFocus += new RoutedEventHandler(this.DistanceFromStart_GotFocus);
        ((UIElement) this.RotatingDistanceFromStartTxNumericEditBox).LostFocus += new RoutedEventHandler(this.DistanceFromStart_LostFocus);
        break;
      case 71:
        this.RotatingRotationAxisLabel = (TextBlock) target;
        break;
      case 72:
        this.RotatingRotationAxisCombo = (ComboBox) target;
        this.RotatingRotationAxisCombo.SelectionChanged += new SelectionChangedEventHandler(this.RotatingRotationAxis_SelectionChanged);
        this.RotatingRotationAxisCombo.GotFocus += new RoutedEventHandler(this.RotationAxis_GotFocus);
        this.RotatingRotationAxisCombo.LostFocus += new RoutedEventHandler(this.RotationAxis_LostFocus);
        break;
      default:
        this._contentLoaded = true;
        break;
    }
  }
}
